//
//  ViewController.m
//  YNIMFrameworkDemo
//
//  Created by 黄旭 on 2021/7/6.
//

#import "ViewController.h"
#import <YNIMFramework/YNIMFramework.h>

@interface ViewController ()<YNXMPPprotocol>

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor=[UIColor redColor];
    
    NSString* userNo = @"ccdfe8e5-c194-4c2c-8b28-5fb59e8a6665";
    NSString *fileName = [NSString stringWithFormat:@"%@.sqlite",userNo];
    NSString *fileDir  = [NSString stringWithFormat:@"%@/Data",userNo];
    
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *dirPath = [paths[0] stringByAppendingPathComponent:fileDir];
    BOOL isDir        = NO;
    BOOL isCreated    = [[NSFileManager defaultManager] fileExistsAtPath:dirPath isDirectory:&isDir];
    if ( isCreated == NO || isDir == NO ) {
        NSError* error    = nil;
        BOOL success      = [[NSFileManager defaultManager] createDirectoryAtPath:dirPath withIntermediateDirectories:YES attributes:nil error:&error];
    }
    
    NSString *filePath = [dirPath stringByAppendingPathComponent:fileName];
    
//    [[YNIMmanager sharedInstance] initXMPPWithServer:@"188.ynedut.cn:6000" companyCode:@"ynedut" imId:userNo userName:@"yn" dbPath:filePath];
    [[YNIMmanager sharedInstance]initXMPPWithServer:@"188.ynedut.cn:6000" companyCode:@"ynedut" imId:userNo userName:@"yn" loginName:@"yn" dbPath:filePath userType:1];
    [[YNIMmanager sharedInstance] addImDelegate:self];
    [[YNIMmanager sharedInstance]addImDelegate:self];
    [[YNIMmanager sharedInstance]addImDelegate:self];
    [[YNIMmanager sharedInstance]removeImDelegate:self];
    [[YNIMmanager sharedInstance]addImDelegate:self];
    [[YNIMmanager sharedInstance]removeImDelegate:self];
    // Do any additional setup after loading the view.
}


@end
